package com.jack.thinking.java._22.swing.bean;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.TooManyListenersException;

import javax.swing.*;

import com.utils.SwingConsole;

public class BangBeanTest extends JFrame{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextField txt = new JTextField(20);
	class BBL implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			txt.setText("Bang action " + count++);
		}
		private int count = 0;
	}
	
	public BangBeanTest() {
		BangBean bb = new BangBean();
		try {
			bb.addActionListener(new BBL());
		} catch (TooManyListenersException e) {
			txt.setText("Too many listeners");
		}
		
		add(bb);
		add(BorderLayout.SOUTH, txt);
	}
	
	public static void main(String[] args) {
		SwingConsole.run(new BangBeanTest(), 400, 500);
	}
}
